
#include <iostream>
#include "sshtml.h"

using namespace std;

int main (int argc, char* argv[])
{
    if(2 > argc)
    {
        cout << "< In file > < out file > \n";
    }
    else
    try // create HTML file
    {
        SSHTML html; // start html file.
        html.setFile(argv[1]);
        html.makeHeading("Hi There",html.getHead());
        html.makeParagraph("This is a comment",html.getHead());
        html.makeHeading("OK Fine",html.getHead(),4);
        html.makeParagraph("We are having fun now",html.getHead());
        html.openTable("newheader");
        html.openTableRow();
        html.setTableHeader("Collem");
        html.setTableHeader("Data1");
        html.closeTableRow();
        html.openTableRow();
        html.setTableHeader("Row1");
        html.setTableData("data1");
        html.closeTableRow();
        html.closeTable();
        html.writeHtml();//argv[1]); // write the xml tree
    }
    catch(const char *error)
    {
        cout << "level 1 "  << error << endl;
    }
    try // add to a table 
    {
        SSHTML html2(argv[1]); // start html file.
        html2.getNextTable(html2.getHead());
        html2.getNextRow(html2.getTable());
        html2.setTableData("data3");
        //html2.getNextRow((html2.getRow())->next);
        html2.setTableHeader("Data3");
        html2.writeHtml();//argv[1]); // write the xml tree
    }
    catch(const char *error)
    {
        cout << "level 2 " << error << endl;
    }
    try // test bits and peaces.
    {
        char *name = new char[strlen(argv[1])+2];
        strcpy(name,argv[1]);
        name[strlen(argv[1])] = 'a';
        name[strlen(argv[1])+1] = 0;
        SSHTML html3(name);
        html3.makeHtml();
        html3.makeHeading("show this works");
        html3.endHtml();
        html3.writeHtml();
        delete[] name;
    }
    catch(const char *error)
    {
        cout << "level 3 " << error << endl;
    }
    
}

